package com.malinkang.sqlite;

import android.content.Context;
import android.database.DatabaseErrorHandler;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.provider.BaseColumns;

/**
 * Created by malinkang on 16/3/28.
 */
public class DBOpenHelper extends SQLiteOpenHelper {

    public static final String DB_NAME = "User.db";

    public static final String USER_TABLE_NAME = "user";

    public static final String COLUMN_AVATAR = "avatar";

    public static final String COLUMN_USERNAME = "username";

    public static final String COLUMN_PHONE = "phone";

    public static final int DB_VERSION = 1;

    public DBOpenHelper(Context context) {
        super(context, DB_NAME, null, DB_VERSION);

    }

    public DBOpenHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version, DatabaseErrorHandler errorHandler) {
        super(context, name, factory, version, errorHandler);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {

        db.execSQL("CREATE TABLE " + USER_TABLE_NAME + " (" + BaseColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
                COLUMN_AVATAR + " TEXT, " + COLUMN_USERNAME + " TEXT ," + COLUMN_PHONE + " TEXT );");

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
